Skip to content

Conversation

berinhard
Copy link
Contributor

@ewdurbin and @dstufft I'm opening this draft PR so we can async talk about the progress of #9503.

Right now this PR introduces:

  1. The new Sponsor model;
  2. A command to load the sponsors into the database;

I'll add inline comments with specific questions I have.

Comment on lines 581 to 582
params["color_logo_url"] = img
params["white_logo_url"] = f"white/{img}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ewdurbin as you've comment, I'm adding the URLs directly, but I don't think we can totally rely on current URLs in Pypi. I mean, take a look at current Google's logo URL:

https://pypi.org/static/images/sponsors/color/google.62f52fb9.png

It has this hash 62f52fb9 suffix that I'm assuming it changes every deploy. So, how can we define the URLs here?

Also, what do you think about the directory structure I proposed: having the colored logo in a directory and all the white logos should be placed in the white children directory with the same file name.

Copy link
Member

@ewdurbin ewdurbin May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That hash is stable as long as pypi-theme doesn't change (and it won't since we broke the hosted private index when we turned off support for non SNI clients 😂 😬 😭 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a good amount of time to review in depth, but I'm not sure if a directory structure is strictly necessary.

Unless there's a good reason for it, I would presume we'll just take whatever image is uploaded, discard the name, and toss it in a static assets bucket under sponsor-logos/{UUID}.png

berinhard added 2 commits May 14, 2021 11:43
I'm used to use direnv to configure env variables. I had to create it to
always have WAREHOUSE_IPYTHON_SHELL enabled.
@berinhard
Copy link
Contributor Author

berinhard commented May 14, 2021

Hey everyone, I did some progress with this!

As you can see, I changed the /sponsors/ page to read the sponsors from the database by replacing the existing template route to a custom view. Although this is the simplest solution I could think and it works for that page, I'm afraid this is not true for the sidebar or footer logos.

From what I've saw in the code, I feel that the csi template tag is a good candidate to go with. But, this will also introduce a conceptual change: now both sidebar and footer will require JS code to display the sponsors. Is this a problem?

I don't think it'll be, but I fell more comfortable asking before coding since I'm new in the project.

(please, do not consider the failing tests because I'm still under seeking for solutions mode. I'll work on them once I know my suggestions are valid alternatives)

@ewdurbin
Copy link
Member

ewdurbin commented May 17, 2021

As you can see, I changed the /sponsors/ page to read the sponsors from the database by replacing the existing template route to a custom view. Although this is the simplest solution I could think and it works for that page, I'm afraid this is not true for the sidebar or footer logos.

From what I've saw in the code, I feel that the csi template tag is a good candidate to go with. But, this will also introduce a conceptual change: now both sidebar and footer will require JS code to display the sponsors. Is this a problem?

I think that the CSI approach has merit, and shows significant consideration on your part to note the additional query necessary on every request to render sponsor information throughout the site. But I think the query for fetching sponsor name, description, inclusion areas (footer/sidebar), and logo url should be fairly lightweight and doable in a single sub millisecond query for each request. Given that, I the caveat of requiring JS to show our sponsor information might be worth making the trade off of adding a new query to every request.

It's also more simple :)

@ewdurbin
Copy link
Member

ewdurbin commented Jun 1, 2021

Note: We should ensure that we sanitize (for JavaScript an any esoteric tags/properties) any strings submitted via Admin before displaying on PyPI.org. This will ensure that even a hijacked Admin/Moderator/Sponsor Coordinator account won't result in an XSS for PyPI.

@berinhard berinhard marked this pull request as ready for review June 7, 2021 11:39
@ewdurbin ewdurbin requested a review from di June 7, 2021 19:51
Copy link
Member

@ewdurbin ewdurbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We reviewed this together on a call to finish our the last few details and get it shippable.

There is one remaining task to enable image uploads that will be handled in a follow-on Pull Request.

Thank you for the thorough work here @berinhard!

Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks solid! Nice work!

xz -d -f -k dev/$(DB).sql.xz --stdout | docker-compose run --rm web psql -h db -d warehouse -U postgres -v ON_ERROR_STOP=1 -1 -f -
docker-compose run --rm web python -m warehouse db upgrade head
$(MAKE) reindex
docker-compose run web python -m warehouse sponsors populate-db
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a plan to run this in production?

As an aside, this is a lot of work for something we only need once. Wow!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will be run then axed.


# user must have base admin access if any admin permission
if principals:
principals.append("group:with_admin_access")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name confused me a bit because of our existing "admins" group, maybe something like:

Suggested change
principals.append("group:with_admin_access")
principals.append("group:with_admin_dashboard_access")

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Fixed in 384278a

@berinhard
Copy link
Contributor Author

Not sure why, but my last build failed but I'm not sure how to fix it. I'm still confused with the dependency management tools we're using. I tried to update the main.txt file using the make command explained in the docs, but the output says it's up to date:

$ make requirements/main.txt
make: 'requirements/main.txt' is up to date.

The error from CI is:

ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
Collecting google-api-core<2.0.0dev,>=1.21.0
    google-api-core<2.0.0dev,>=1.21.0 from https://files.pythonhosted.org/packages/f6/72/6dc3c3c4576fedc409fd825bf71e22d0f448bd68143c79cdbd6216744282/google_api_core-1.30.0-py2.py3-none-any.whl#sha256=92cd9e9f366e84bfcf2524e34d2dc244906c645e731962617ba620da1620a1e0 (from google-cloud-core==1.6.0->-r requirements/main.txt (line 280))
Error: Process completed with exit code 1.

But google-api-core do have 2 hash entries in requirements/main.txt and this branch is up to date the main one after @ewdurbin commit 96d9d4f.

I'm not sure what went wrong =S

@ewdurbin
Copy link
Member

ewdurbin commented Jun 8, 2021

dang, looks like we're hitting the google api dependency breakage again 😵

@berinhard
Copy link
Contributor Author

Not sure if this is related, but they've released a new package version 1 hour ago: https://pypi.org/project/google-api-core/#history

@di
Copy link
Member

di commented Jun 8, 2021

Technically not google-api-core's fault, just how pypa/pip#9644 manifests here.

The solution is to upgrade to the latest version.

@berinhard
Copy link
Contributor Author

Thanks @di! I hope I managed to fix this on #9636

@ewdurbin
Copy link
Member

ewdurbin commented Jun 8, 2021

Right, not blaming the app itself, to rephrase, once again struck by pypa/pip#9644, which is triggered by google-api dependency. (our only with extras)

@ewdurbin
Copy link
Member

ewdurbin commented Jun 8, 2021

aight! let's rebase and ship this!

@ewdurbin ewdurbin merged commit 51410fe into pypi:main Jun 8, 2021
miketheman added a commit to miketheman/warehouse that referenced this pull request Jun 9, 2023
The underlying datatype for URLType is `Text` and we don't use any of
the functionality from the type at all.

Introduced in pypi#9512

We don't need to carry the library any further.

Signed-off-by: Mike Fiedler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants